{capture assign='listingId'}{if $listing_id}{$listing_id}{else}{$listing.id}{/if}{/capture}
{if $GLOBALS.is_ajax || $smarty.get.ajax_submit}

	{foreach from=$errors key=key item=error}
		{if $key == 'NOT_SUPPORTED_VIDEO_FORMAT' || $key == 'NOT_ACCEPTABLE_FILE_FORMAT'}
			<p class="error">[[Not supported video format]]</p>
		{elseif $key === 'UPLOAD_ERR_INI_SIZE'}
			<p class="error">[[File size exceeds system limit. Please check the file size limits on your hosting or upload another file.]]</p>
		{else}
			<p class="error">{$key}</p>
		{/if}
	{/foreach}

	<input type="file"
		   field_id="{if $complexField}{$complexField}:{$id}:{$complexStep}{else}{$id}{/if}"
		   field_action="upload_classifieds_video{if $complexField}_complex{/if}"
		   field_target="video_field_content_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}"
		   name="{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
		   class="autouploadField {if $complexField}complexField{/if}"
		   id="input_video_{$id}"
		   {if $value.file_url}style="display:none;"{/if}/>
	{if !$value.file_url}
		<small>([[max.]] {$uploadMaxFilesize} M)</small>
	{/if}

	<span id="video_uploader_image_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}" style="display: none;">&nbsp;<img src="{$GLOBALS.user_site_url}/templates/_system/main/images/ajax_preloader_circular_16.gif" /></span>

		{if $complexField && $filesInfo.$complexStep.file_name ne null}
			<div id="classifieds_video_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}" style="float:left;">
				<div class="complex-view-file-caption">
					<a onclick="popUpWindow('{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}', 282, 300, 'VideoPlayer'); return false;" href="{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}"> [[Watch a video]]</a>
					|
					{if $copy_listing ne null}
					{*<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listing_id}&amp;action=delete&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}">[[Remove]]</a>
									<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />*}
					{else}
						<a class="delete_video_complex"
						   listing_id="{$listingId}"
						   field_id="{$complexField}:{$id}:{$complexStep}"
						   file_id="{$filesInfo.$complexStep.file_id}"
						   href="{$GLOBALS.site_url}/classifieds/delete-complex-file/?listing_id={$listingId}&amp;field_id={$complexField}:{$id}:{$complexStep}&amp;file_id={$filesInfo.$complexStep.file_id}">[[Remove]]</a>
		
					{/if}
					<br/><br/>
				</div>
				<input type="hidden" field_id="{$id}" field_action="upload_classifieds_video" field_target="#video_field_content_{$id}" id="hidden_{$complexField}_{$id}_{$complexStep}" name="{$complexField}[{$id}][{$complexStep}]" value="{$filesInfo.$complexStep.file_id}" class="complexField"/>
			</div>
			<span id="extra_field_info_{$id}" style="display:none;"><small>([[max.]] {$uploadMaxFilesize} M)</small></span>
		{elseif !$complexField && $value.file_name ne null && $url != '/add-listing/'}
			<div id="classifieds_video_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}" style="float:left;">
				<a onclick="popUpWindow('{$GLOBALS.site_url}/video-player/?videoFileId={$value.file_id}&listing_id={$listingId}&amp;field_id={$id}', 282, 300, 'VideoPlayer'); return false;" href="{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}"> [[Watch a video]]</a>
				|
				{if $copy_listing ne null}
					<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listingId}&amp;action=delete&amp;field_id={$id}">[[Remove]]</a>
					<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />
				{else}
					<a class="delete_classifieds_video" listing_id="{$listingId}" field_id="{$id}" file_id="{$value.file_id}" href="{$GLOBALS.site_url}/classifieds/delete-uploaded-file/?listing_id={$listingId}&amp;field_id={$id}">[[Remove]]</a>
				{/if}
				<br/><br/>
			</div>
			<span id="extra_field_info_{$id}" style="display:none;"><small>([[max.]] {$uploadMaxFilesize} M)</small></span>
		{/if}
{else}
	<div id="video_field_content_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}">
		<div class="errors"></div>

		<input type="file"
			field_id="{if $complexField}{$complexField}:{$id}:{$complexStep}{else}{$id}{/if}"
			field_action="upload_classifieds_video{if $complexField}_complex{/if}"
			field_target="video_field_content_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}"
			name="{if $complexField}{$complexField}[{$id}][{$complexStep}]{else}{$id}{/if}"
			class="autouploadField {if $complexField}complexField{/if}"
			id="input_video_{$id}"
			{if $value.file_url}style="display:none;"{/if} />
		{if !$value.file_url}
			<small>([[max.]] {$uploadMaxFilesize} M)</small>
		{/if}
		
		<span id="video_uploader_image_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}" style="display: none;">&nbsp;<img src="{$GLOBALS.user_site_url}/templates/_system/main/images/ajax_preloader_circular_16.gif" /></span>

		{if $complexField && $filesInfo.$complexStep.file_name ne null}
			<div id="classifieds_video_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}" style="float:left;">
				<div class="complex-view-file-caption">
					<a onclick="popUpWindow('{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}', 282, 300, 'VideoPlayer'); return false;" href="{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}"> [[Watch a video]]</a>
					|
					{if $copy_listing ne null}
					{*<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listing_id}&amp;action=delete&amp;field_id={$id}&amp;complexParent={$complexField}&amp;complexEnum={$complexStep}">[[Remove]]</a>
					<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />*}
						{else}
						<a class="delete_video_complex"
						   listing_id="{$listingId}"
						   field_id="{$complexField}:{$id}:{$complexStep}"
						   file_id="{$filesInfo.$complexStep.file_id}"
						   href="{$GLOBALS.site_url}/classifieds/delete-complex-file/?listing_id={$listingId}&amp;field_id={$complexField}:{$id}:{$complexStep}&amp;file_id={$filesInfo.$complexStep.file_id}">[[Remove]]</a>
					{/if}
					<br/><br/>
				</div>
				<input type="hidden" id="hidden_{$complexField}_{$id}_{$complexStep}" name="{$complexField}[{$id}][{$complexStep}]" value="{$filesInfo.$complexStep.file_id}" class="complexField"/>
			</div>
			<span id="extra_field_info_{$id}" style="display:none;"><small>([[max.]] {$uploadMaxFilesize} M)</small></span>
		{elseif !$complexField && $value.file_name ne null && $url != '/add-listing/'}
			<div id="classifieds_video_{if $complexField}{$complexField}_{$id}_{$complexStep}{else}{$id}{/if}" style="float:left;">
				<a onclick="popUpWindow('{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}', 282, 300, 'VideoPlayer'); return false;" href="{$GLOBALS.site_url}/video-player/?listing_id={$listingId}&amp;field_id={$id}"> [[Watch a video]]</a>
				|
				{if $copy_listing ne null}
					<a href="{$GLOBALS.site_url}/clone-job/?listing_id={$listingId}&amp;action=delete&amp;field_id={$id}">[[Remove]]</a>
					<input type="hidden" name="{$id}_hidden{if $complexField}[{$complexStep}]{/if}" value="1" />
				{else}
					<a class="delete_classifieds_video" listing_id="{$listingId}" field_id="{$id}" file_id="{$value.file_id}" href="{$GLOBALS.site_url}/classifieds/delete-uploaded-file/?listing_id={$listingId}&amp;field_id={$id}">[[Remove]]</a>
				{/if}
				<br/><br/>
			</div>
			<span id="extra_field_info_{$id}" style="display:none;"><small>([[max.]] {$uploadMaxFilesize} M)</small></span>
		{/if}
	</div>

	<script>
		{literal}
		// check temporary uploaded data of field
		$(function() {
			{/literal}
			{if $complexField}
				getComplexClassifiedsVideoData('{$complexField}:{$id}:{$complexStep}', '{$listingId}', '{if $listing.type.id}{$listing.type.id}{/if}');
			{else}
				getClassifiedsVideoData('{$id}', '{$listingId}');
			{/if}
			{literal}
		});

		{/literal}
	</script>

{/if}